﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Stertex.Service;
using Stertex.Repository;
using Stertex.Service.Exceptions;
using Stertex.Common.Extensions;
namespace Stertex.Service
{
    public class ProfileService : ServiceCore<Repository.Profile>
    {

        public void UpdateProfile(Profile profile)
        {
            var oldProfile = FirstOrDefault(p => p.ProfileID == profile.ProfileID);
            if (oldProfile == null)
            {
                throw new EntityNotExistException();
            }
            //
            oldProfile.CopyPropertiesFrom(profile,"ProfileID");
            //oldProfile.Address = profile.Address;
            //oldProfile.City = profile.City;
            //oldProfile.Company = profile.Company;
            //oldProfile.Firstname = profile.Firstname;
            //oldProfile.Lastname = profile.Lastname;
            //oldProfile.Phone = profile.Phone;
            UnitOfWork.Commit();
               
        }
    }
}
